home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
IRIX 6.2 Applications 1996 May
/
SGI IRIX 6.2 Applications 1996 May.iso
/
dist
/
impr_dev.idb
/
usr
/
impressario
/
src
/
models
/
laserjetPJL_model.z
/
laserjetPJL_model
Wrap
Text File
|
1996-05-06
|
33KB
|
971 lines
#!/bin/sh
#
# NOTE FOR DEVELOPERS:
#
# Please see the template_model.README file for more information
# about the structure and conventions in this file. See also 'man sh'
#
# Also note that wherever you MUST change something for your printer,
# you should find an "XXX". Search for them to see what you'll change.
#
# Please REMOVE all developer comments and XXX'es from this file.
# They are for developer's eyes only, and shouldn't be in a final product.
#
# Change the first line of this file to '#!/bin/sh -x' for debugging output.
#
# This is the lp printer interface file for HP LaserJet printers
# that support PJL. Supported printers are listed below.
#
# Information for the printer installation tools. Do not change the
# NAME strings or these lines because these are parsed by various
# Impressario utilities.
#
# XXX Add names of supported printers below
#
# NAME=HP LaserJet 4V, DEVICE=CENTRONICS, OPTIONS=faceup=0
# NAME=HP LaserJet 4V, DEVICE=NETPRINTER, OPTIONS=faceup=0 NETWORK=1 OUTSOCK=9100
# NAME=HP LaserJet 4P, DEVICE=CENTRONICS, OPTIONS=faceup=0
# NAME=HP LaserJet 4P, DEVICE=NETPRINTER, OPTIONS=faceup=0 NETWORK=1 OUTSOCK=9100
# NAME=HP LaserJet 4 Plus, DEVICE=CENTRONICS, OPTIONS=faceup=0
# NAME=HP LaserJet 4 Plus, DEVICE=NETPRINTER, OPTIONS=faceup=0 NETWORK=1 OUTSOCK=9100
# NAME=HP LaserJet 4Si, DEVICE=CENTRONICS, OPTIONS=faceup=0
# NAME=HP LaserJet 4Si, DEVICE=NETPRINTER, OPTIONS=faceup=0 NETWORK=1 OUTSOCK=9100
# NAME=HP LaserJet 5L, DEVICE=CENTRONICS, OPTIONS=faceup=0
# NAME=HP LaserJet 5P, DEVICE=CENTRONICS, OPTIONS=faceup=0
# NAME=HP LaserJet 5P, DEVICE=NETPRINTER, OPTIONS=faceup=0 NETWORK=1 OUTSOCK=9100
# NAME=HP LaserJet 5Si, DEVICE=CENTRONICS, OPTIONS=faceup=0
# NAME=HP LaserJet 5Si, DEVICE=NETPRINTER, OPTIONS=faceup=0 NETWORK=1 OUTSOCK=9100
#
# Note: Do not change ANY characters up to the = in the next two assignments:
# various printer tools search for these EXACT characters.
NAME=
# XXX Change the TYPE= line to be the appropriate type.
TYPE=Raster
# XXX Change GUI_CLASS= line to Xt class name of graphical options panel.
GUI_CLASS=LaserJetPJL
# First grab the command line arguments passed to the model file:
printer=`basename $0` # the printer's name
jobid=$1 # job sequence id number
username=$2 # user name
title="$3" # job title
copies=$4 # number of copies
options="$5" # -o options
shift 5 # discard args up to filenames
files="$*" # input file(s)
##################################################################
#
# This section includes our global variable definitions.
#
##################################################################
# Append the stderr output of the filters and drivers to error log file:
logfile=/var/spool/lp/log # lp spooler error log file
exec 2>> $logfile
# The directories and files used by this interface file:
TMPDIR=/var/tmp # Directory to store temporary files
export TMPDIR # Export so all programs we call use it
HOME=/var/spool/lp # Home used by cms libraries
export HOME
printdir=/usr/lib/print # Path to filter/driver directory
datadir=$printdir/data # Path to data directory
screendir=$datadir/screens # Path to dir with PostScript screens
# Boolean flags:
#
debug=0 # Print debug info to log file?
exitcode=0 # Error code to report on exit?
faceup=0 # Does printer stack faceup?
banner=1 # Print a banner page? #XXX
bestfit=1 # Rotate image to best fit?
usefastpath=1 # Use fast path for text files? #XXX
reversetext=0 # Reverse text document page order?
# XXX If using psrip make sure you have these so you can check for
# a failed license:
# File with info to display to user whe/if the psrip license expires:
psrip_expired_msg=$datadir/psrip_expired_msg
licensedaysleft="" # Days left in license. 0 == no limit
# If printing to a printer directly connected to the network then
# NETWORK should be set to 1 and NETPRINTER is the name or IP address
# of the network printer (name typically found in /etc/hosts).
# OUTSOCK is the TCP port number to connect to on the network print
# server. HP uses 9100 so use that. An external network adaptor (as
# opposed to a network card installe in the printer) is probably what
# would be used for 5P -- so OUTSOCK will have to be set for
# the particular network adaptor (HP JetDirect EX is 9100, EX Plus 3 is
# 9100, 9101, 9102 for ports 1, 2 and 3, respectivly).
NETWORK=0
NETPRINTER=
OUTSOCK=9100
# General integer variables:
tagjobid=0 # Process ID of tagging process: 0=none.
##################################################################
#
# Locations and options for filters and drivers:
# All of the variables that are exported are used by fileconvert(1)
# and will be set in the command string that fileconvert returns.
# Non-printer-specific filters and drivers:
# Text to PostScript Filter Options:
text2ps=$printdir/text2ps
IMPR_TEXT2PSOPTS="-J$printer"
export IMPR_TEXT2PSOPTS
# SGI Image to PostScript Filter Options:
IMPR_SGI2PSOPTS="-C w -B" #XXX
export IMPR_SGI2PSOPTS
# Other Image to STIFF Filter Options:
IMPR_IMG2STIFFOPTS=""
export IMPR_IMG2STIFFOPTS
# PostScript Page Order Manipulation Filter Options:
IMPR_PSFILTOPTS=""
export IMPR_PSFILTOPTS
# PostScript to Raster Bitmap Filter and Options:
# XXX Not used for native PostScript printers.
psrip=$printdir/psrip
IMPR_PSRIPOPTS="-S -P $printer -C k -B 1 -F planar "
export IMPR_PSRIPOPTS
# File Typer and File Type Converter:
filetyper=/usr/sbin/wstype
filetyperopts="-d /usr/lib/filetype/workspace.ctr"
fileconvert=/usr/sbin/fileconvert
fileconvertopts="-c /usr/lib/filetype/workspace.ctr"
# Printer Driver and options (run driver with -h to get usage) XXX
driver=$printdir/laserjetPJL
driveropts="-P $printer -B 262144 "
# Driver to drive the parallel port XXX
#
plpdriver=$printdir/phandler
plpdriveropts="-P $printer -K -B 262144 "
# Driver to drive the network. You can use -a1 or -a3 if the printer
# understands PJL job commands. -a1 for built-in JetDirect; -a3 for
# jetdirect EX. You can also use -w if you want the printer to send
# back page info each time a pgae prints (a page count is then displayed
# on the PrintStatus screen). -w locks the rinter until all pages print
# which keeps the printer from doing a 'job look ahead' (in other words it
# can't start receiving data for next job until all pages print). -a
# somtimes cause the JetDirect card to lock-up if the Job is canceled. XXX
netdriver=$printdir/hpnpf
netdriveropts="-P $printer -x $NETPRINTER -j$jobid+$username -p $OUTSOCK "
###netdriveropts="-a1 -w -P $printer -x $NETPRINTER -j$jobid+$username -p $OUTSOCK "
# "Fast Path" Text to Native Printer Format Converter: #XXX
#
text2pcl=$printdir/text2pcl
IMPR_TEXT2PCLOPTS="-P $printer"
export IMPR_TEXT2PCLOPTS
##################################################################
#
# This section defines convenience functions for later use.
#
##################################################################
SetDebug() #XXX
#
# This routine turns on debug mode for all appropriate programs.
{
# Non-printer-specific filters:
#
debug=1
IMPR_PSRIPOPTS="$IMPR_PSRIPOPTS -D" #XXX
IMPR_SGI2PSOPTS="$IMPR_SGI2PSOPTS -D"
IMPR_IMG2STIFFOPTS="$IMPR_IMG2STIFFOPTS -D"
IMPR_TEXT2PSOPTS="$IMPR_TEXT2PSOPTS -Q"
# Printer-specific filters:
#
driveropts="$driveropts -D"
plpdriveropts="$plpdriveropts -D"
netdriveropts="$netdriveropts -l $logfile -s $logfile"
IMPR_TEXT2PCLOPTS="$IMPR_TEXT2PCLOPTS -D" #XXX
}
SetDeviceDriver()
#
# Set the driver for the output device to drive a parallel port or
# a network device
{
if [ $NETWORK != 0 ]; then
devdriver="$netdriver"
devdriveropts="$netdriveropts"
else
devdriver="$plpdriver"
devdriveropts="$plpdriveropts"
fi
}
CheckRipLicense()
{
# XXX Use this routine to check for a psrip software license if using
# psrip. Edit /var/flexlm/license.dat for testing this section.
#
# psrip is based on Adobe CPSI Level 2 PostScript interpreter and is a
# licensed product. It uses a node-locked FLEXlm license. This
# routine makes sure there is a valid license and sets up the variable
# licensedaysleft which the banner page program will use to warn of
# impending failure. If the license has expired it prints a simple
# banner page with the contents of the file $psrip_expired_msg and
# disables the printer queue (this is done so print jobs are not
# dropped). Note that once an Impressario license is installed
# it will be valid forever (only demo and temporary licenses expire).
# Note devdriver used so this routine should be called after
# devdriver is setup.
# Call the program that checks for a license. This is a quick
# (light-weight) way to check (as opposed to starting up psrip).
# chkimprlicense returns -1 (aka 255) if a license is not available
# or if a system call error occurred trying to get a license. 0 is
# returned if there is a valid license. If the license will expire
# in the next 90 days a value of 1 to 90 is returned.
$printdir/chkimprlicense
licensedaysleft="$?"
if [ "$licensedaysleft" = "255" ]; then
# No license. Print a banner page with info. Log same info
# to ~lp/log. Tag printer as failed. Put message up so
# printpanel will display it. Disable the spooler and specify
# license failure as the reason the spooler is disabled.
# First, print a single page with job info and contents of file
# $psrip_expired_msg (which have instructions on getting
# a license and restarting the spooler). Use text2pcl for output.
# The sed command substitutes the printer name for the string
# --printername-- in the $psrip_expired_msg file to make it
# more informative.
# XXX The way this banner page is generated will vary with the
# printer. You have to generate it without psrip.
echo "\n\n`banner $username`\n\nJob Info: $jobid $printer `date`\n\n\n`sed s/--printername--/$printer/g $psrip_expired_msg`" \
| $text2pcl -P $printer \
| $driver $driveropts -F pcl \
| $devdriver $devdriveropts 1>>/dev/null 2>&1
# Send same info to the ~lp/log file
echo "\n`sed s/--printername--/$printer/g $psrip_expired_msg`" >>$logfile
# Set printer status to failed and post a message. We use
# chkimprlicense again to do this (it will set the printer s
# status on failure if the printer name is bassed; also, it
# will add the error message if passed on the command line).
# The message is displayed on the Printer Status Panel (when
# printstatus is run). We do this after calling $devdriver above
# because it will set status to idle when done. This leaves the
# status of the printer as FAULTED to catch user's attention.
$printdir/chkimprlicense -P$printer \
-m"License expired. See log file /var/spool/lp/log on `hostname`." 2>&1
# Disable the queue so jobs are not dropped. After license is installed
# user does an 'enable queuename' and jobs will print.
disable -r"Impressario software license has expired." \
$printer 1>>$logfile 2>&1
exit 2
elif [ $licensedaysleft -gt 0 ]; then
# License will expire in next 90 days. Force banner on so number
# of days till expiration is seen. If the file
# /usr/lib/print/no_banner_warning exist then do not force banner.
if [ ! -f "$printdir/no_banner_warning" ]; then
banner=1
fi
# Log a warning
echo "$printer: WARNING Impressario software license expires in $licensedaysleft days." >>$logfile
else
# License OK.
# Set licensedaysleft to blank so it will not appear on banner page.
licensedaysleft=""
fi
}
ReportUnknownOption()
#
# Prints a useful error message when an unknown option is parsed.
# Expects the unknown option as argument 1 and the filename as arg 2.
{
echo $printer: $jobid $username : Unknown command line \\c >> $logfile
echo option :: $1 :: while printing the following: \\c >> $logfile
echo :: $2 :: - `date` >> $logfile
}
PrintMessage()
#
# Prints a text-only error message to the printer.
# Expects the strings to print as arguments, in order.
# Separates strings by spaces, so make sure to insert newlines appropriately.
{
#XXX Uses psrip
echo $* \
| $text2ps -J$printer \
| $psrip $IMPR_PSRIPOPTS -C k -B 1 \
| $driver $driveropts \
| $devdriver $devdriveropts 1>>/dev/null 2>&1
#XXX This uses fast text path, you may not want to.
#echo $* \
# | $text2pcl -P $printer \
# | $devdriver $devdriveropts 1>>/dev/null 2>&1
# XXX If you had a native PostScript printer, you'd use:
# echo $* \
# | $text2ps -J$printer \
# |$devdriver $devdriveropts 1>>/dev/null 2>&1
}
BeginTagging()
#
# This routine sets up the printer icon tagging job.
{
poddir=/var/spool/lp/pod # Path to POD directory
interfacedir=/var/spool/lp/interface # Path to interface directory
$printdir/tagit $interfacedir/$printer $poddir/$printer.status \
$TYPE 10 1 2> /dev/null &
tagjobid=$!
}
EndTagging()
#
# This routine tells the tagging job, if any, to stop tagging the printer.
{
if [ $tagjobid -gt 0 ]; then
kill -TERM $tagjobid 2> /dev/null
fi
}
CleanUpAfterJob()
#
# Performs any required cleanup at the end of each job.
{
if [ $debug != 0 ]; then
echo "Cleaning up after job." >> $logfile
fi
EndTagging
}
SetCancelTrap()
#
# This routine sets up the proper trap command.
# When a job is cancelled, the spooler sends us a SIGTERM.
# We could also get a SIGHUP or a SIGINT, so we'll catch those.
#
# It removes any temporary/intermediate files created while filtering.
# It also calls EndTagging to stop the backgrounded tagging process.
{
trap 'CleanUpAfterJob
exit' 1 2 15 # catch SIGHUP, SIGINT, and SIGTERM
}
ReportBadFile()
#
# Report unknown file type to printer log and spooler log.
# Expects as arguments the filename and filetype, in that order.
# Sets the global flag exitcode to indicate a bad file was sent.
{
filetype="`$filetyper $filetyperopts $1 | /usr/bin/cut -d\ -f2-`"
echo "$printer: File '$1' is of unprintable type '$filetype'.\n" \
>> $logfile
PrintMessage "Printer $printer could not print file '$1'\n" \
"Fileconvert could not convert this file of type" \
" '$filetype' to a printable format.\n"
exitcode=8
}
TestExitStatus()
#
# Checks exit status from last executed command and reports
# an intelligent error message if and only if an error has occurred.
# Expects as argument 1 the exit code of the last command.
# Expects as argument 2 a string describing the last command.
# Expects as argument 3 the file or files being processed.
{
# NOTE TO DEVELOPERS:
# The following list are error codes specific to the driver.
# If the driver exits with an error code, we want to present
# the user with a useful error message so they'll understand
# what really happened, not just get an 'error code X' message.
#
# NOTE: We include only one example error code for brevity.
# REMEMBER: You must change these errorcodes for each driver!
#
err_emptyinput=12; # Driver received empty or short input file
case $1 in
#
# Handle the common driver errors explicitly, so user gets
# better idea what went wrong rather than just uninformative
# message "an error occurred."
#
0 ) # no error, do nothing
;;
$err_emptyinput )
# Driver reported empty input file.
# The usual cause of this is that upstream filters died.
echo $printer: Exit code $1 while $2. >> $logfile
PrintMessage "Printer $printer could not print file '$3':\n" \
"The printer driver reported that an empty" \
" or incomplete image was produced by fileconvert.\n\n" \
"HINT: Was the PostScript code valid?" \
" Did it include a 'showpage' command?\n" \
"Check the spooler log file $logfile for more details.\n" \
"The PostScript interpreter may have reported" \
" an error in the logfile."
;;
* ) # default case, print mostly useless error message.
echo $printer: Exit code $1 while $2. >> $logfile
PrintMessage "Could not print file '$3':\n" \
"Exit code $1 while $2."
;;
esac
}
PrintBannerPage()
#
# Prints a banner page by appending the username, realusername, jobid,
# printername, timestamp, and BannerPage routine invocation
# onto a pre-defined PostScript banner program and then
# printing the resulting PostScript program.
#
{
# Location for banner page program
#
# System Admins: Uncomment BannerFaces and comment out BannerPage if you
# have either /usr/lib/faces or /usr/local/lib/faces mounted,
# and you wish to have users' faces printed on the banner pages.
#
# Developers: Do NOT ship BannerFaces by default! Using BannerFaces requires
# that /usr/lib/faces or /usr/local/lib/faces be mounted.
# This is not true at many customer sites.
#
#bannerprogram=$datadir/BannerFaces
bannerprogram=$datadir/BannerPage
if [ ! -f $bannerprogram ]; then
echo "$printer: ERROR: Unable to find $bannerprogram file." >> $logfile
echo "$printer: Banner Page can not be printed." >> $logfile
return
fi
# Get the user's real name if we can.
#
realname=`finger -bfmp $username|nawk '{print substr($3, 2); exit}' FS=':'`
# Send the prolog file and the job specific info to the PS renderer:
#
#XXX For a native PS printer, remove the line with psrip in it. The
# last argument, ($licensedaysleft), is optional. If ($licensedaysleft)
# is not blank the banner page warnms the user that license will
# expire in $licensedayslef from now.
echo "($realname) ($username) ($jobid) ($printer) (`date`) ($title) ($licensedaysleft) BannerPage" \
| cat $bannerprogram - \
| $psrip $IMPR_PSRIPOPTS \
| $driver $driveropts -d off \
| $devdriver $devdriveropts 1>>/dev/null 2>&1
# Report intelligent error if we failed
#
TestExitStatus $? "printing banner page" "Impressario Banner Page"
}
ParseOptions()
#
# Parses -o command line options and sets appropriate global variables.
{
# Loop through the options, shifting off those read at end of loop.
#
count=$#
while [ "$count" -gt 0 ]
do
case $1 in
#
# General model file options
#
# Print a banner page?
#
-banner | banner) argcnt=1; banner=1 ;;
-nobanner | nobanner | -h | h)
argcnt=1; banner=0 ;;
# Print debug (verbose) messages into spooler log file?
#
-debug | debug) argcnt=1; SetDebug ;;
-verbose | verbose) argcnt=1; SetDebug ;;
-noverbose | noverbose) argcnt=1; ;;
#
# Non-printer-specific filtering options
#
# General filtering options:
#
#
# set halftone. The argument is the name of a screen file
# in $screendir.
-halftone | halftone) argcnt=2;
IMPR_PSRIPOPTS="$IMPR_PSRIPOPTS -I $screendir/$2";;
#
# Printer-specific filtering options:
#
# What horizontal and vertical resolutions to print at:
-resolution | resolution) argcnt=3;
driveropts="$driveropts -X $2 -Y $3";;
# What papersize to request?
-papersize | papersize) argcnt=2;
IMPR_TEXT2PCLOPTS="$IMPR_TEXT2PCLOPTS -S $2"; #XXX
driveropts="$driveropts -S $2";;
# Economode Option
-economode | economode) argcnt=1;
driveropts="$driveropts -j Economode";;
# Darkness option
-darkness | darkness) argcnt=2;
driveropts="$driveropts -j $2";;
# Manual feed option
-manual | manual) argcnt=1;
driveropts="$driveropts -T manual";;
#Media tray
-tray | tray) argcnt=2;
driveropts="$driveropts -T $2";;
-intray | intray) argcnt=2;
driveropts="$driveropts -T $2";;
# Output Tray
-outtray | outtray) argcnt=2;
if [ $2 = "rear" ]; then
driveropts="$driveropts -Rrear";
faceup=1;
reversetext=1;
usefastpath=0;
else
driveropts="$driveropts -Rtop";
faceup=0;
reversetext=0;
fi
;;
#Duplex
-duplex | duplex) argcnt=2;
driveropts="$driveropts -d $2";;
# PostScript page order filter options
#
# Print the specified page range, two integer page numbers
-pspagerange | pspagerange) argcnt=3;
usefastpath=0;
IMPR_PSFILTOPTS="$IMPR_PSFILTOPTS -p$2-$3" ;;
# Reverse the PostScript page order
-psreversepage | psreversepage) argcnt=1;
usefastpath=0;
IMPR_PSFILTOPTS="$IMPR_PSFILTOPTS -r" ;;
# Select odd pages only
-psoddpage | psoddpage) argcnt=1;
usefastpath=0;
IMPR_PSFILTOPTS="$IMPR_PSFILTOPTS -o" ;;
# Select even pages only
-psevenpage | psevenpage) argcnt=1;
usefastpath=0;
IMPR_PSFILTOPTS="$IMPR_PSFILTOPTS -e" ;;
# Image filter options:
#
# Rotate the image in integer degrees
-rotate | rotate) argcnt=2;
IMPR_SGI2PSOPTS="$IMPR_SGI2PSOPTS -r $2";
bestfit=0 ;;
# Rotate the final image to the best fit orientation
-bestfit | bestfit) argcnt=1; bestfit=1 ;;
# Flip the image, producing a mirror image.
-flip | flip) argcnt=1;
IMPR_SGI2PSOPTS="$IMPR_SGI2PSOPTS -f" ;;
# Scale the image to fit the page.
# Takes a float argument, see appropriate man pages.
-zoom | zoom) argcnt=2;
IMPR_SGI2PSOPTS="$IMPR_SGI2PSOPTS -z $2";;
# Scale the final image size to match the
# specified input resolution, in pixels per inch.
-ppi | ppi) argcnt=2;
IMPR_SGI2PSOPTS="$IMPR_SGI2PSOPTS -p $2";;
# Set the amount of gamma warping for the image
-gamma | gamma) argcnt=2;
IMPR_SGI2PSOPTS="$IMPR_SGI2PSOPTS -G $2";;
# Text filter options
#
# If you get any of these switches, set "usefastpath=0",
# to use the PostScript filter on the text instead of the
# fast path text filter (if your printer supports one.)
# Use PostScript for text processing.
-pstext | pstext) argcnt=1; usefastpath=0 ;;
# Page orientation
-landscape | landscape) argcnt=1; usefastpath=0 ;
IMPR_TEXT2PSOPTS="$IMPR_TEXT2PSOPTS -H" ;;
-portrait | portrait) argcnt=1; usefastpath=0 ;
IMPR_TEXT2PSOPTS="$IMPR_TEXT2PSOPTS -V" ;;
# Font name, argument is font name as specified in man page
# for the filter associated with $text2ps.
-fontname | fontname) argcnt=2; usefastpath=0 ;
IMPR_TEXT2PSOPTS="$IMPR_TEXT2PSOPTS -F$2";;
# Font size, in points, a positive integer.
-fontsize | fontsize) argcnt=2; usefastpath=0 ;
IMPR_TEXT2PSOPTS="$IMPR_TEXT2PSOPTS -P$2bp" ;;
# Margin sizes: top, bottom, left and right margins specified
# as <float_value> [in | cm | mm]
-topmargin | topmargin) argcnt=3; usefastpath=0 ;
IMPR_TEXT2PSOPTS="$IMPR_TEXT2PSOPTS -T$2$3" ;;
-bottommargin | bottommargin) argcnt=3; usefastpath=0 ;
IMPR_TEXT2PSOPTS="$IMPR_TEXT2PSOPTS -B$2$3" ;;
-leftmargin | leftmargin) argcnt=3; usefastpath=0 ;
IMPR_TEXT2PSOPTS="$IMPR_TEXT2PSOPTS -L$2$3" ;;
-rightmargin | rightmargin) argcnt=3; usefastpath=0 ;
IMPR_TEXT2PSOPTS="$IMPR_TEXT2PSOPTS -R$2$3" ;;
# Number of columns on page, a non-negative integer
-columns | columns) argcnt=2; usefastpath=0 ;
IMPR_TEXT2PSOPTS="$IMPR_TEXT2PSOPTS -M$2";;
# Number each page : [tb][lcr] [number]
-numberpages | numberpages) argcnt=3; usefastpath=0 ;
IMPR_TEXT2PSOPTS="$IMPR_TEXT2PSOPTS -N$2$3";;
# Reverse the page order?
-reversepages | reversepages) argcnt=1; usefastpath=0 ;
reversetext=1 ;;
-noreversepages | noreversepages) argcnt=1; usefastpath=0 ;
reversetext=0 ;;
# Gaudy page header
-gaudy | gaudy) argcnt=1; gaudymode=1; usefastpath=0 ;;
-nogaudy | nogaudy) argcnt=1; gaudymode=0 ;;
# Preformatted manual page printing
-manpage | manpage) argcnt=1; usefastpath=0;
IMPR_TEXT2PSOPTS="$IMPR_TEXT2PSOPTS -F Courier10 \
-S plain -M 1 -K 66 -m fit" ;;
#
# All other options are discarded with an appropriate message
#
*) argcnt=1; ReportUnknownOption $1 $files ;;
esac
shift $argcnt
count=`expr $count - $argcnt`
done
# Now do post-processing on the parsed arguments.
# Set the gaudy mode for the text filter:
#
if [ "$gaudymode" = 1 ]; then
IMPR_TEXT2PSOPTS="$IMPR_TEXT2PSOPTS -G -O 0.4pt" ;
fi
# Turn on page reversal if required.
#
if [ $reversetext != 0 ]; then
IMPR_PSFILTOPTS="$IMPR_PSFILTOPTS -r";
fi
# Should BestFit mode be turned on in sgi2ps?
#
if [ $bestfit != 0 ]; then
IMPR_SGI2PSOPTS="$IMPR_SGI2PSOPTS -F";
fi
# Insert the number of copies operator for text2pcl for fast path cases.
#
IMPR_TEXT2PCLOPTS="$IMPR_TEXT2PCLOPTS -n $copies" #XXX
}
##################################################################
#
# This section is the actual body of the interface program.
#
##################################################################
# Set the device driver string before checking it, below.
#
SetDeviceDriver
# verify that our prerequisites are in place.
#
# In our case, the minimum check includes checking that:
# the log file is writable, the printer type is set and
# the driver, and filter file exist.
#
# Ideally, if an error were detected, we would respool the job
# after disabling the printer but before exiting.
# This would preserve the print job instead of dropping it on the floor.
# Set LOGNAME to ensure we can disable a printer queue:
LOGNAME=lp
export LOGNAME
if [ ! -w "$logfile" ]; then
disable -r"Can't write to spooler log. Please check permissions." \
$printer 2>&1
exit 2
fi
if [ "$TYPE" = "" ]; then
disable -r"Printer type not defined. Please reinstall printer." \
$printer 1>>$logfile 2>&1
exit 2
fi
if [ ! -x "$driver" ]; then
disable -r"$driver is not an executable. Please reinstall $driver." \
$printer 1>>$logfile 2>&1
exit 2
fi
if [ ! -x "$devdriver" ]; then
disable -r"$devdriver is not an executable. Please reinstall $devdriver." \
$printer 1>>$logfile 2>&1
exit 2
fi
# Make sure we can read /usr/lib/DPS/AdobeFonts.upr.
#
if [ ! -r /usr/lib/DPS/AdobeFonts.upr ]; then
disable -r"/usr/lib/DPS/AdobeFonts.upr missing. Install dps_eoe.sw.dps on print server." \
$printer 1>>$logfile 2>&1
echo "$printer: /usr/lib/DPS/AdobeFonts.upr missing. Install dps_eoe.sw.dps on print server." 1>>$logfile 2>&1
exit 2
fi
# Future releases of Irix will not have .ctr files (routeprint will
# map .ctr to .otr for printing at that time). We will no longer
# check for the workspace.ctr file
#
#if [ ! -r /usr/lib/filetype/workspace.ctr ]; then
# disable -r"WorkSpace filetype database not built. Please type 'su ; cd /usr/lib/filetype ; make'" \
# $printer 1>>$logfile 2>&1
# exit 2
#fi
##################################################################
# Set up the signal handler to handle jobs cancellation
#
SetCancelTrap
# Now parse the options passed using the -o switch:
#
ParseOptions $options
# Re-set the device driver after options parsed.
#
SetDeviceDriver
# Check that we have a license to run the Adobe PostScript interpreter
CheckRipLicense
# Report that the job has begun:
#
if [ $debug != 0 ]; then
echo $printer: $jobid $username "$title" Start - `date` >> $logfile
echo $printer: "options: $options" >> $logfile
fi
# Update the status database before job filtering starts.
# This is required because printer config may have changed between
# jobs, and because the driver will update the status file that
# the filters read.
# This is used for forcibly updating dynamic printer options like resolution.
#
$driver -s $driveropts
# Fire off the sub-process which will tag this model file
# with the appropriate print engine type and status for active icons:
#
BeginTagging
##################################################################
#
# Now do the real printing:
# (1) Print a banner page if requested.
# (2) Typecheck and filter each file in $files one by one.
# Print the banner page first if the printer prints face down:
#
if [ $banner != 0 -a $faceup = 0 ]; then
PrintBannerPage
fi
for file in $files
do
# Try converting it to printer driver format data using fileconvert.
# For this printer only, if no options have been set which
# prevent us from using PCL, we first ask for an ImpressarioPCLFile
# since we know this printer accepts PCL. We do this because
# we know that PCL prints simple text quickly, and we want to
# take advantage of that "fast path."
if [ $usefastpath = 1 ]; then #XXX
CMD=`$fileconvert $fileconvertopts -d ImpressarioPCL_4_File $file 2> /dev/null`
if [ $? = 0 ]; then
# OK, conversion successful, execute the returned sh cmd
# and send the results to the printer. We go thru $driver
# because it will add PJL/PCL wrapper to implement options
# such as paper drawer, etc.
if [ $debug != 0 ]; then
# Log the commands that actually get run.
echo "$printer: CMD:$CMD | $driver $driveropts -F pcl | $devdriver $devdriveropts " >> $logfile
echo "$printer: IMPR_TEXT2PCLOPTS=$IMPR_TEXT2PCLOPTS" >> $logfile
exec 2>> $logfile
fi
sh -c "$CMD" | $driver $driveropts -F pcl \
| $devdriver $devdriveropts 1>>/dev/null 2>&1
# Report intelligent error if we failed
#
TestExitStatus $? "Processing $file via $fileconvert" $file
# OK, now skip to the next file
continue;
fi
fi
# Use fileconvert to convert to the printer's native format.
# For raster printers, it is ImpressarioRasterBitmap.
# For PostScript printers, it is ImpressarioPostScriptFile.
#
CMD=`$fileconvert $fileconvertopts -d ImpressarioRasterBitmap $file 2> /dev/null` #XXX
if [ $? = 0 ]; then
# OK, conversion successful, execute the returned sh cmd file
# and send the results to the printer.
if [ $debug != 0 ]; then
# Log the commands that actually get run.
echo "$printer: CMD:$CMD | $driver $driveropts -n $copies" >> $logfile
echo "$printer: IMPR_SGI2PSOPTS:$IMPR_SGI2PSOPTS" >> $logfile
echo "$printer: IMPR_PSRIPOPTS:$IMPR_PSRIPOPTS" >> $logfile
echo "$printer: IMPR_TEXT2PSOPTS:$IMPR_TEXT2PSOPTS" >> $logfile
echo "$printer: IMPR_IMG2STIFFOPTS:$IMPR_IMG2STIFFOPTS" >> $logfile
echo "$printer: IMPR_PSFILTOPTS:$IMPR_PSFILTOPTS" >> $logfile
exec 2>> $logfile
fi
# The network driver requires "1>>/dev/null 2>&1" or it will hang
sh -c "$CMD" | $driver $driveropts -n $copies \
| $devdriver $devdriveropts 1>>/dev/null 2>&1
# Report intelligent error if we failed
#
TestExitStatus $? "Processing $file via $fileconvert" $file
else
# Couldn't convert it to printable format, so give up.
#
ReportBadFile $file
fi
done
# Print the banner page last if the printer prints face up:
#
if [ $banner != 0 -a $faceup != 0 ]; then
PrintBannerPage
fi
##################################################################
#
# Done filtering all files. Clean up and exit.
# Perform any cleanups that had to wait until the job ended.
#
CleanUpAfterJob
# Report end of job.
#
if [ $debug != 0 ]; then
echo $printer: $jobid End - `date` >> $logfile
fi
# Now check whether we had unsupported file types in the file list
# If so, exit with that code.
#
exit $exitcode